/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Control.ControlVeterinarian;
import java.awt.Toolkit;
import java.util.Date;
import javax.swing.text.MaskFormatter;

/**
 *
 * @author Nicolas
 */
public class VeterinarianCreatePanel extends javax.swing.JPanel {

    private HPVAS father;
    
    public VeterinarianCreatePanel(HPVAS father) {
        initComponents();
        this.setVisible(true);
        this.father = father;
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        create_button = new javax.swing.JButton();
        cancel_button = new javax.swing.JButton();
        name_text = new javax.swing.JTextField();
        lastName_text = new javax.swing.JTextField();
        dia_text = new javax.swing.JTextField();
        mes_text = new javax.swing.JTextField();
        ano_text = new javax.swing.JTextField();
        birthPlace_text = new javax.swing.JTextField();
        focusPractice_text = new javax.swing.JTextField();
        specialities_text = new javax.swing.JTextField();
        salary_text = new javax.swing.JTextField();
        graduatetAt_text = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        ssn_text = new javax.swing.JFormattedTextField(createFormatter("###-##-####"));

        setMaximumSize(new java.awt.Dimension(465, 284));
        setMinimumSize(new java.awt.Dimension(465, 284));

        jLabel1.setText("Veterinarian");

        jLabel2.setText("Name");

        jLabel3.setText("Last Name");
        jLabel3.setMaximumSize(new java.awt.Dimension(27, 14));
        jLabel3.setMinimumSize(new java.awt.Dimension(27, 14));
        jLabel3.setPreferredSize(new java.awt.Dimension(27, 14));

        jLabel4.setText("SSN");
        jLabel4.setMaximumSize(new java.awt.Dimension(27, 14));
        jLabel4.setMinimumSize(new java.awt.Dimension(27, 14));
        jLabel4.setPreferredSize(new java.awt.Dimension(27, 14));

        jLabel5.setText("BirthDate");
        jLabel5.setMaximumSize(new java.awt.Dimension(27, 14));
        jLabel5.setMinimumSize(new java.awt.Dimension(27, 14));
        jLabel5.setPreferredSize(new java.awt.Dimension(27, 14));

        jLabel6.setText("BirthPlace");
        jLabel6.setMaximumSize(new java.awt.Dimension(27, 14));
        jLabel6.setMinimumSize(new java.awt.Dimension(27, 14));
        jLabel6.setPreferredSize(new java.awt.Dimension(27, 14));

        jLabel7.setText("Focus of Practice");

        jLabel8.setText("Specialities");

        jLabel9.setText("Salary");

        jLabel10.setText("Graduated At");

        create_button.setText("Create");
        create_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                create_buttonActionPerformed(evt);
            }
        });

        cancel_button.setText("Cancel");
        cancel_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancel_buttonActionPerformed(evt);
            }
        });

        dia_text.setColumns(2);
        dia_text.setText("Dia");
        dia_text.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                dia_textMouseClicked(evt);
            }
        });
        dia_text.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dia_textActionPerformed(evt);
            }
        });
        dia_text.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                dia_textFocusGained(evt);
            }
        });
        dia_text.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                dia_textKeyTyped(evt);
            }
        });

        mes_text.setColumns(2);
        mes_text.setText("Mes");
        mes_text.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                mes_textMouseClicked(evt);
            }
        });
        mes_text.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mes_textActionPerformed(evt);
            }
        });
        mes_text.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                mes_textFocusGained(evt);
            }
        });
        mes_text.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mes_textKeyTyped(evt);
            }
        });

        ano_text.setColumns(4);
        ano_text.setText("Año");
        ano_text.setName(""); // NOI18N
        ano_text.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ano_textMouseClicked(evt);
            }
        });
        ano_text.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                ano_textFocusGained(evt);
            }
        });
        ano_text.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                ano_textKeyTyped(evt);
            }
        });

        jLabel11.setText("*100.000.000");

        ssn_text.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ssn_textActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(cancel_button, javax.swing.GroupLayout.PREFERRED_SIZE, 182, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(create_button, javax.swing.GroupLayout.DEFAULT_SIZE, 253, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGap(23, 23, 23)
                                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 72, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(graduatetAt_text))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(salary_text))
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                        .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 55, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(name_text)
                                    .addComponent(lastName_text)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(dia_text, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(mes_text, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(ano_text, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(0, 0, Short.MAX_VALUE))
                                    .addComponent(birthPlace_text)
                                    .addComponent(ssn_text, javax.swing.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(specialities_text))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(focusPractice_text)))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(name_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(8, 8, 8)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lastName_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ssn_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dia_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(mes_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(ano_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 12, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(birthPlace_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(focusPractice_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(specialities_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9)
                            .addComponent(salary_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel11))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(graduatetAt_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(create_button)
                    .addComponent(cancel_button))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void create_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_create_buttonActionPerformed
        Date d = new Date(Integer.parseInt(ano_text.getText().trim()),Integer.parseInt(mes_text.getText().trim()),Integer.parseInt(dia_text.getText().trim()));
        ControlVeterinarian cv = new ControlVeterinarian();
        cv.createVeterinarian(name_text.getText().trim(),lastName_text.getText().trim(), ssn_text.getText().trim(), d, birthPlace_text.getText().trim(),focusPractice_text.getText().trim(), specialities_text.getText().trim(), Integer.parseInt(salary_text.getText().trim()), graduatetAt_text.getText().trim());
        father.setCurrent_panel(new MainPanel());
        father.change_panel();
    }//GEN-LAST:event_create_buttonActionPerformed

    private void cancel_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancel_buttonActionPerformed
        father.setCurrent_panel(new MainPanel());
        father.change_panel();
    }//GEN-LAST:event_cancel_buttonActionPerformed

    private void dia_textActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dia_textActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_dia_textActionPerformed

    private void dia_textMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_dia_textMouseClicked
        if(dia_text.getText().equals("Dia")){
            dia_text.setText("");
        }
    }//GEN-LAST:event_dia_textMouseClicked

    private void mes_textMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mes_textMouseClicked
        if(mes_text.getText().equals("Mes")){
            mes_text.setText("");
        }
    }//GEN-LAST:event_mes_textMouseClicked

    private void ano_textMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ano_textMouseClicked
        if(ano_text.getText().equals("Año")){
            ano_text.setText("");
        }
    }//GEN-LAST:event_ano_textMouseClicked

    private void dia_textFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_dia_textFocusGained
        if(dia_text.getText().equals("Dia")){
            dia_text.setText("");
        }
    }//GEN-LAST:event_dia_textFocusGained

    private void mes_textFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_mes_textFocusGained
        if(mes_text.getText().equals("Mes")){
            mes_text.setText("");
        }
    }//GEN-LAST:event_mes_textFocusGained

    private void ano_textFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_ano_textFocusGained
        if(ano_text.getText().equals("Año")){
            ano_text.setText("");
        }
    }//GEN-LAST:event_ano_textFocusGained

    private void mes_textActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mes_textActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_mes_textActionPerformed

    private void dia_textKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_dia_textKeyTyped
        if (dia_text.getText().length()== 2){
            evt.consume();
            Toolkit.getDefaultToolkit().beep();
        }
    }//GEN-LAST:event_dia_textKeyTyped

    private void mes_textKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mes_textKeyTyped
        if (mes_text.getText().length()== 2){
            evt.consume();
            Toolkit.getDefaultToolkit().beep();
        }
    }//GEN-LAST:event_mes_textKeyTyped

    private void ano_textKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ano_textKeyTyped
        if (mes_text.getText().length()== 4){
            evt.consume();
            Toolkit.getDefaultToolkit().beep();
        }
    }//GEN-LAST:event_ano_textKeyTyped

    private void ssn_textActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ssn_textActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ssn_textActionPerformed

    protected MaskFormatter createFormatter(String s) {
    MaskFormatter formatter = null;
    try {
        formatter = new MaskFormatter(s);
    } catch (java.text.ParseException exc) {
        System.err.println("formatter is bad: " + exc.getMessage());
        System.exit(-1);
    }
    return formatter;
}
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField ano_text;
    private javax.swing.JTextField birthPlace_text;
    private javax.swing.JButton cancel_button;
    private javax.swing.JButton create_button;
    private javax.swing.JTextField dia_text;
    private javax.swing.JTextField focusPractice_text;
    private javax.swing.JTextField graduatetAt_text;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JTextField lastName_text;
    private javax.swing.JTextField mes_text;
    private javax.swing.JTextField name_text;
    private javax.swing.JTextField salary_text;
    private javax.swing.JTextField specialities_text;
    private javax.swing.JFormattedTextField ssn_text;
    // End of variables declaration//GEN-END:variables
}
